updating the ratings

packages

library(tidyverse) # CRAN v1.3.0 
library(progress) # CRAN v1.2.2 
library(ggrepel)
library(lubridate)
library(conflicted) # CRAN v1.0.4
conflict_prefer("filter", "dplyr") 
[conflicted] Will prefer dplyr::filter over any other package
source("functions.R")
source("cleaning.R")
source("estimation.R")
source("graphs.R")
source("display.R")
options(dplyr.summarise.inform = FALSE)

load up latest games and “pre” ratings

games <- read_rds("~/Documents/r-projects/scoresway/rds/games.rds")
with_pre <- read_rds("wpre.rds")
with_pre

updated ratings

k <- 20
options(dplyr.summarise.inform = FALSE)
pb <- progress_bar$new(format = " progress [:bar] :percent eta: :eta", total = nrow(with_pre), width = 40)
with_pre %>% 
  mutate(rat=map2(this, pre, ~this_ratings(.x, .y, k, games))) %>% 
  mutate(post=map(rat, "r")) %>% 
  mutate(updates=map(rat, "d")) -> with_post

 progress [>-------------]   4% eta:  6s
 progress [>-------------]   5% eta:  6s
 progress [>-------------]   6% eta:  6s
 progress [>-------------]   8% eta:  6s
 progress [>-------------]   9% eta:  7s
 progress [>-------------]  10% eta:  7s
 progress [=>------------]  11% eta:  7s
 progress [=>------------]  13% eta:  7s
 progress [=>------------]  14% eta:  7s
 progress [=>------------]  15% eta:  7s
 progress [=>------------]  16% eta:  6s
 progress [=>------------]  18% eta:  6s
 progress [==>-----------]  19% eta:  6s
 progress [==>-----------]  20% eta:  6s
 progress [==>-----------]  22% eta:  6s
 progress [==>-----------]  23% eta:  6s
 progress [==>-----------]  24% eta:  6s
 progress [===>----------]  25% eta:  6s
 progress [===>----------]  27% eta:  6s
 progress [===>----------]  28% eta:  6s
 progress [===>----------]  29% eta:  6s
 progress [===>----------]  30% eta:  6s
 progress [===>----------]  32% eta:  6s
 progress [====>---------]  33% eta:  6s
 progress [====>---------]  34% eta:  5s
 progress [====>---------]  35% eta:  5s
 progress [====>---------]  37% eta:  5s
 progress [====>---------]  38% eta:  5s
 progress [====>---------]  39% eta:  5s
 progress [=====>--------]  41% eta:  5s
 progress [=====>--------]  42% eta:  5s
 progress [=====>--------]  43% eta:  5s
 progress [=====>--------]  44% eta:  5s
 progress [=====>--------]  46% eta:  4s
 progress [======>-------]  47% eta:  4s
 progress [======>-------]  48% eta:  4s
 progress [======>-------]  49% eta:  4s
 progress [======>-------]  51% eta:  4s
 progress [======>-------]  52% eta:  4s
 progress [======>-------]  53% eta:  4s
 progress [=======>------]  54% eta:  4s
 progress [=======>------]  56% eta:  4s
 progress [=======>------]  57% eta:  3s
 progress [=======>------]  58% eta:  3s
 progress [=======>------]  59% eta:  3s
 progress [========>-----]  61% eta:  3s
 progress [========>-----]  62% eta:  3s
 progress [========>-----]  63% eta:  3s
 progress [========>-----]  65% eta:  3s
 progress [========>-----]  66% eta:  3s
 progress [========>-----]  67% eta:  3s
 progress [=========>----]  68% eta:  3s
 progress [=========>----]  70% eta:  2s
 progress [=========>----]  71% eta:  2s
 progress [=========>----]  72% eta:  2s
 progress [=========>----]  73% eta:  2s
 progress [=========>----]  75% eta:  2s
 progress [==========>---]  76% eta:  2s
 progress [==========>---]  77% eta:  2s
 progress [==========>---]  78% eta:  2s
 progress [==========>---]  80% eta:  2s
 progress [==========>---]  81% eta:  2s
 progress [===========>--]  82% eta:  1s
 progress [===========>--]  84% eta:  1s
 progress [===========>--]  85% eta:  1s
 progress [===========>--]  86% eta:  1s
 progress [===========>--]  87% eta:  1s
 progress [===========>--]  89% eta:  1s
 progress [============>-]  90% eta:  1s
 progress [============>-]  91% eta:  1s
 progress [============>-]  92% eta:  1s
 progress [============>-]  94% eta:  1s
 progress [============>-]  95% eta:  0s
 progress [============>-]  96% eta:  0s
 progress [=============>]  97% eta:  0s
 progress [=============>]  99% eta:  0s
 progress [==============] 100% eta:  0s
                                        
with_post

save

write_rds(with_post, "wpost.rds")

read

with_post <- read_rds("wpost.rds")

look at all

see post values sorted in tabs

since_hrs <- 24
with_post %>% 
  mutate(latest=map_dbl(updates, ~max(.$time_stamp))) %>% 
  mutate(since=(now()-as_datetime(latest))/dhours(1)) %>% 
  filter(since<=since_hrs) -> wp2
wp2

not quite right yet

disp("iceland")
Error in View : argument "league_name" is missing, with no default

see post values sorted in tabs

# read_csv("wanted.txt") %>% pull(want) -> wants
# wants
# with_post <- read_rds("wpost.rds")
# with_post %>% filter(league %in% wants) %>%  # edit/remove slice
wp2 %>% 
  arrange(desc(league)) %>% 
  select(post, updates, league) %>% 
  pwalk(~display(..1, ..2, ..3)) # first input to pwalk can be a df

plot

# time_graph("england 2", with_post)
map(wp2$league, ~time_graph(., with_post))
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
Joining, by = "team"
[[1]]

[[2]]

[[3]]

[[4]]

[[5]]

[[6]]

[[7]]

[[8]]

[[9]]

[[10]]

[[11]]

[[12]]

[[13]]

[[14]]

[[15]]

[[16]]

[[17]]

[[18]]

[[19]]

[[20]]

[[21]]

[[22]]

[[23]]

[[24]]

[[25]]

[[26]]

LS0tCnRpdGxlOiAidXBkYXRpbmciCm91dHB1dDogaHRtbF9ub3RlYm9vawotLS0KCiMgdXBkYXRpbmcgdGhlIHJhdGluZ3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